//
//  LJJGoodsTopImageView.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/18.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJGoodsTopImageView.h"
#import <SDCycleScrollView.h>

@interface LJJGoodsTopImageView ()

@property (strong, nonatomic) SDCycleScrollView *headImageView;    /** 头部的轮播图 **/
@property (strong, nonatomic) UILabel *buyNumLabel;    /** 购买量 **/

@end

@implementation LJJGoodsTopImageView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.headImageView];
        [self addSubview:self.buyNumLabel];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [_buyNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(90, 22));
        make.bottom.equalTo(weakSelf.mas_bottom).offset(-30);
        make.right.equalTo(weakSelf.mas_right).offset(11);
    }];
}
- (void)setImageArray:(NSArray *)imageArray
{
    _imageArray = imageArray;
    _headImageView.imageURLStringsGroup = imageArray;
}
- (void)setBuyNum:(NSString *)buyNum
{
    _buyNum = buyNum;
    _buyNumLabel.text = buyNum;
}
#pragma mark -
#pragma mark - lazy method
- (SDCycleScrollView *)headImageView
{
    if (!_headImageView) {
        _headImageView = [[SDCycleScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 380)];
        _headImageView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
        _headImageView.currentPageDotColor = [UIColor whiteColor];
    }
    return _headImageView;
}

- (UILabel *)buyNumLabel
{
    if (!_buyNumLabel) {
        _buyNumLabel = [[UILabel alloc] init];
        _buyNumLabel.text = @"100人已购买";
        _buyNumLabel.backgroundColor = RGB(230, 51, 37, 1);
        _buyNumLabel.textColor = [UIColor whiteColor];
        _buyNumLabel.layer.masksToBounds = YES;
        _buyNumLabel.layer.cornerRadius = 11.0;
        _buyNumLabel.font = [UIFont systemFontOfSize:11.0];
        _buyNumLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _buyNumLabel;
}

@end
